package com.dyna.chat.controller;

import com.dyna.chat.domain.req.msg.ChatMessageReq;
import com.dyna.chat.domain.resp.msg.ChatMessageResp;
import com.dyna.chat.service.ChatService;
import com.dyna.domain.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api("聊天")
@RestController
@RequestMapping("/chat")
public class ChatController {

    private final ChatService chatService;

    @Autowired
    public ChatController(ChatService chatService) {
        this.chatService = chatService;
    }

    @PostMapping("/msg")
    @ApiOperation("发送消息")
    public R<ChatMessageResp> sendMsg(@Valid @RequestBody ChatMessageReq request) {
        return R.data(chatService.sendMsg(request));
    }

}
